<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">立库搬运任务id</label>
        <el-input v-model="query.wmsTaskId" clearable placeholder="立库搬运任务id" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">轨道车搬运任务id</label>
        <el-input v-model="query.agvTaskId" clearable placeholder="轨道车搬运任务id" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">载盘码</label>
        <el-input v-model="query.palletCode" clearable placeholder="载盘码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">任务类型</label>
        <!-- <el-input v-model="query.orderType" clearable placeholder="配送单类型 1离库, 2 回库, 3缓存区至产线" style="width: 160px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
        <el-select v-model="query.orderType" class="filter-item" style="width: 160px;" filterable placeholder="请选择类型" @change="crud.toQuery">
          <el-option
            v-for="item in dict.delivery_type"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <label class="el-form-item-label">任务状态</label>
        <el-select v-model="query.status" class="filter-item" style="width: 160px;" filterable placeholder="请选择状态" @change="crud.toQuery">
          <el-option
            v-for="item in dict.delivery_status"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <!-- <el-table-column type="selection" width="55" /> -->
        <el-table-column prop="agvTaskId" label="轨道车搬运任务id" />
        <el-table-column prop="palletCode" label="载盘码" />
        <el-table-column prop="fromLocation" label="起点" />
        <el-table-column prop="toLocation" label="终点" />
        <el-table-column prop="orderType" label="配送单类型">
          <template slot-scope="scope">
            {{ dict.label.delivery_type[scope.row.orderType] }}
          </template>
        </el-table-column>
        <el-table-column prop="status" label="任务状态">
          <template slot-scope="scope">
            {{ dict.label.delivery_status[scope.row.status] }}
          </template>
        </el-table-column>
        <!-- <el-table-column v-if="checkPer(['admin','deliveryOrderHistory:edit','deliveryOrderHistory:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDeliveryOrderHistory from '@/api/deliveryOrderHistory'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, area: null, wmsTaskId: null, agvTaskId: null, palletCode: null, fromLocation: null, toLocation: null, orderType: null, status: null }
export default {
  name: 'DeliveryOrderHistory',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['delivery_status', 'delivery_type', 'delivery_area'],
  cruds() {
    return CRUD({ title: '配送单历史记录', url: 'api/deliveryOrderHistory', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDeliveryOrderHistory },
      optShow: {
        add: false,
        edit: false,
        download: true,
        del: false,
        reset: true
      }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'deliveryOrderHistory:add'],
        edit: ['admin', 'deliveryOrderHistory:edit'],
        del: ['admin', 'deliveryOrderHistory:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'wmsTaskId', display_name: '立库搬运任务id' },
        { key: 'agvTaskId', display_name: '轨道车搬运任务id' },
        { key: 'palletCode', display_name: '载盘码' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
